package com.huike;

import com.huike.common.utils.MyConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 启动程序
 */

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class})
@EnableScheduling
@Slf4j
public class HuiKeApplication{

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(HuiKeApplication.class, args);
        Environment env = applicationContext.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = MyConvertUtils.getString(env.getProperty("server.servlet.context-path"));
        log.info("server started\n----------------------------------------------------------\n\t" +
                "汇客服务器 is running! Access URLs:\n\t" +
                "Local: \t\t\thttp://localhost:" + port + path + "\n\t" +
                "External: \t\thttp://" + ip + ":" + port + path + "\n\t" +
                "Swagger文档: \thttp://" + ip + ":" + port + path + "doc.html\n\t" +
                "NGINX: \t\t\thttp://" + ip + ":8088" + "\n" +
                "----------------------------------------------------------");
    }

}
